# 字符串专题

# 1.str中嵌套引号时，外层必须使用双引号
course = "Python's Course for Beginners"
print(course)
print("========")

# 2.打印多行内容时，使用三引号
email_content = """
Hi JetBrains,

This is my second time to apply student licensed.

Thank you,
AnonyEast    
"""
print(email_content)
print("========")

# 3.通过索引打印字符串中的某个字符
print(course[2])  # t
print(course[1])  # y
print(course[0])  # P
print(course[-1])  # s
print(course[-2])  # r
print("========")

# 4.通过索引打印字符串中的多个字符
# 格式:[起始位置:结束位置:步进值]
# startIndex:endIndex 打印索引为startIndex到endIndex-1的字符
print(course[0:6])  # Python
# 不输入endIndex时，将从startIndex的位置打印到字符串结束
print(course[9:])  # Course for Beginners
# 不输入startIndex时，将从索引0打印到endIndex-1
print(course[:6])  # Python
# 两边都不输入时，可以将整个字符串打印，当然一般不这么做
print(course[:])
print("========")

# 5.将截取的字符串赋值给其他的str变量
# 截取索引为-9到-2之间字符串
another = course[-9:-1]
print(another)  # Beginner
# 截取索引为1到-2之间的字符串
another = course[1:-1]  # ython's Course for Beginner
print(another)
# 截取索引为0到7之间的字符串
another = course[:8]  # Python's
print(another)
# 截取索引为5到0之间的字符串
another = course[5:1]  # 空字符串，不能从右往左取
print(another)
print("========")

# 6.通过逗号输出多个字符串，默认使用空格分割
print("www", "anonyeast", "top")  # 输出结果：www anonyeast top
# 通过sep指定分割方式
print("www", "anonyeast", "top", sep=".")  # 输出结果：www.anonyeast.top

# 7.若不想输出后换行，使用end，end的默认值是换行符
# 直接在字符串内部写转义字符也是可以的
print("Hello", end="")
print("World", end="\t")
print("Hello", end="")
print("Python", end="\n")
print("end")
'''
    以上输出结果
    HelloWorld	HelloPython
    end 
'''

# 8.输出多次
print("hello,python\n" * 3)

